function whenDocumentReady(){
	initUserListCategorys();
	initFormParam();	//初始化页面
	clickRegisterForStudyApply();
	createConditionForStudyApply();
	
	//已经登录
	if($("input#top_user_login_tag").length>0){
		if($("#user_type_flag").val()==1){
			ajax4ValPulishGoods();
			ajax4ValInvitation();
			ajax4ValJoinInvitation();
		}
		if($("#user_type_flag").val()==0){
			ajax4ValJoinInvitation();
		}
	}

    //弹出关闭发送课程邀请框
    $('.cd-popup-trigger-study').on('click', function(event){
        if(!setCurrentLine($(this))){
            return false;
        }
        var judgeData=$(this).attr("data");
		var studyId="";
		var studentNum=0;
		if(judgeData==0){
			var allstudy=$(".study_check:checked");
			if(allstudy.length<=0){
				clickautohide("请先选择至少一个求学!",3);
				return ;
			}
			for(var i=0;i<allstudy.length;i++){
				studyId=studyId+$(allstudy[i]).val()+",";
				studentNum=studentNum+ parseInt($(allstudy[i]).attr("data"));
			}
		}
		else{
			studyId=$(this).parent().parent().find("#stu_check").val();
			studentNum=$(this).parent().parent().find("#stu_check").attr("data");
		}
		 event.preventDefault();
		 $.ajax({
			type:"post",
			url:_appRoot+"/userCenter/getUpStatusGoodsList",
			dataType:"json",
			success: function(data){
				if(data.result==1){
					var list = data.goodsList;
					var optionHtml="";
					for(var i=0;i<list.length;i++){
						optionHtml+="<option data='"+list[i].goodsId+"' dataindex='"+list[i].notes+"'>"+list[i].goodsName+"</option>";
					}
					$("#class_address").val(list[0].notes);
					$("#courseSelect").html(optionHtml);
					$('#cd-popup-study').fadeIn(300);
					$('#cd-popup-study .cd-popup-container').fadeIn(300);
				}
				else{
					clickautohide(data.message,3);
				}
			}
		});
        
		$(".shu_m").text(studentNum);
		$("#send_stu_id").val(studyId);

		var invication = $("#hiddenInvication");
		var cookieLoginTime=getCookie("lastLoginTime");
		var lastLoginTime=$("#lastLoginTime").val();
		if(cookieLoginTime==lastLoginTime){
			var courseText=getCookie("lastCourseText");
				if(courseText!=null && courseText!=""){
				$("#zmd_h").val(courseText);
			}
		}else{
			$("#zmd_h").val("");
		}
		
		//$("#zmd_h").val($(invication).find("#content").val());
		//$("#goods_name").val($(invication).find("#goodsName").val());
		//$("#goods_url").val($(invication).find("#goodsUrl").val());
		//$("#class_address").val($(invication).find("#address").val());
		$("#teacher_name").val($(invication).find("#teacherName").val());
		$("#teacher_phone").val($(invication).find("#phone").val());
		
		if(($("#text_tip").length>0)&&($("#zmd_h").val()=="")){
			$("#text_tip").show();
		}else if($("#text_tip").length>0){
			$("#text_tip").hide();
		}/*ie789*/
		
		var invitationSwtich = $("#invitationSwtich").val();
		if(invitationSwtich==1){
			$("#open_auto").attr("checked",true);
		}else{
			$("#close_auto").attr("checked",true);
		}
		$("#send_button").removeAttr("disabled","disabled");
		countChar('.zmd_h',200,'.yi_yy');
    });
        //close popup
    $('#cd-popup-study').on('click', function(event){
        if( $(event.target).is('.closebtn2') || $(event.target).is('#cd-popup-study') || $(event.target).is('#boxCancel2')) {
            event.preventDefault();
            $(this).fadeOut(300);
            $('#cd-popup-study .cd-popup-container').fadeOut(300);
			$("#yi_yy").text(0);
        }
    });
    //close popup when clicking the esc keyboard button
    $(document).keyup(function(event){
        if(event.which=='27'){
            $('#cd-popup-study').fadeOut(300);
            $('#cd-popup-study .cd-popup-container').fadeOut(300);
			$("#yi_yy").text(0);
        }
    });
	
	//弹出加入求学
    $('.cd-popup-trigger-studyjoin').on('click', function(event){
        if(!setCurrentLine($(this))){
            return false;
        }
        event.preventDefault();
        $('#cd-popup-studyjoin').fadeIn(300);
        $('#cd-popup-studyjoin .cd-popup-container').fadeIn(300);
        $('#cd-popup-studyjoin').find("input:text,textarea").val("");
		
		$("#study_id").val($(this).attr("data"));
		$("#text_box").val($("#botton_people").val());
		$(".qiu_username").val($("#botton_name").val());
		$(".qiu_userphone").val($("#botton_phone").val());
		$(".qiu_email").val($("#botton_email").val());
		if(($("#email_tip").length>0)&&($(".qiu_email").val()=="")){
			$("#email_tip").show();
		}
		else if($("#email_tip").length>0){
			$("#email_tip").hide();
		}/*ie789*/
		$(".qiu_time").val($("#botton_contactTime").val());
    });
    //close popup
    $('#cd-popup-studyjoin').on('click', function(event){
        if( $(event.target).is('.closebtn1') || $(event.target).is('#cd-popup-studyjoin') || $(event.target).is('#boxCancel1')) {
            event.preventDefault();
            $(this).fadeOut(300);
            $('#cd-popup-studyjoin .cd-popup-container').fadeOut(300);
			$("#adddiv input").remove();
			$(".dele_btu").remove();
        }
    });
    //close popup when clicking the esc keyboard button
    $(document).keyup(function(event){
        if(event.which=='27'){
            $('#cd-popup-studyjoin').fadeOut(300);
            $('#cd-popup-studyjoin .cd-popup-container').fadeOut(300);
			$("#adddiv input").remove();
			$(".dele_btu").remove();
        }
    });
}
	
	//初始化页面
	function initFormParam(){
		//初始化地址
		var address = $("#address").val();
		$("#s1").sjldfromdata("#sh1","#ch1","#qu1",address);
		//初始化求学方式
		var goodsTypes = $("#goodsType").val();
		var goods_types=$(".goods_type"); 
		var goodsArr = new Array();
		goodsArr = goodsTypes.split(",");
		for(var i=0;i<goodsArr.length;i++){
			if(goodsArr[i] =='0')
				$(goods_types[0]).attr("checked", true);
			else if(goodsArr[i]=='1')
				$(goods_types[2]).attr("checked", true);
			else if(goodsArr[i]=='2')
				$(goods_types[1]).attr("checked", true);
			else if(goodsArr[i]=='6')
				$(goods_types[3]).attr("checked", true);
			else if(goodsArr[i]==-'1')
				$(goods_types[4]).attr("checked", true);
		}
		
		//初始化辅导方式
		var t_fdType = $("#t_fdType").val();
		var typeArr = new Array();
		typeArr = t_fdType.split(",");
		for(var i=0;i<typeArr.length;i++){
			$("#fd_"+typeArr[i]).attr("checked",true);
		}
		
		
		//初始化团队、个人
		var isTeam=$("#t_isTeam").val();
		$(".main_wzl").removeClass("main_wzl");
		if(isTeam==0)
			$("#all").addClass("main_wzl");
		else if(isTeam==1)
			$("#alone").addClass("main_wzl");
		else if(isTeam==2)
			$("#team").addClass("main_wzl");
		//初始化是否在线
		var isOnlyOnline=$("#t_isOnline").val();
		if(isOnlyOnline==0){	
			$("#only_online").attr("checked",false);
		}
		else $("#only_online").attr("checked",true);
		//初始化排序
		var orderStyle=$("#t_orderFiledFlat").val();
		if(orderStyle==0)
			$("#time_order").attr("selected", true); 
		else $("#num_order").attr("selected", true); 
	}
	
	//查询已经发送过邀请的求学
	function ajax4ValInvitation(){
		var input_contactIds = $(".s_contactIds");
		var contactIds = "";
		for(var i = 0;i<input_contactIds.length;i++){
			contactIds+=$(input_contactIds[i]).val()+",";
		}
		$.ajax({
			type:"POST",
			url:"/userCenter/ajax4ValInvitation",
			data:{contactIds:contactIds},
			dataType:"json",
			success: function(data){
				if(data.result==1){
					var list = data.list;
					for(var i=0;i<list.length;i++){
						$("#study_"+list[i]).find("#stu_check").attr("disabled","disabled");
						$("#study_"+list[i]).find("#fa_s").html("<a class='al_invited'>已邀请</a>");
					}
				}
			}
		});
	}
	
	//查询已加入的求学
	function ajax4ValJoinInvitation(){
		var input_contactIds = $(".s_contactIds");
		var contactIds = "";
		for(var i = 0;i<input_contactIds.length;i++){
			contactIds+=$(input_contactIds[i]).val()+",";
		}
		$.ajax({
			type:"POST",
			url:"/userCenter/ajax4ValJoinInvitation",
			data:{contactIds:contactIds},
			dataType:"json",
			success: function(data){
				if(data.result==1){
					var list = data.joinList;
					for(var i=0;i<list.length;i++){
						$("#study_"+list[i]).find("#zui_h a").addClass("disabled").unbind("click");
						$("#study_"+list[i]).find("#zui_h a").html("已加入");
					}
				}
			}
		});
	}	
 //初始化三级分类
	var _L=0;//选中的分类所属级
    var _L1=0;//一级分类的索引
    var _L2=0;//二级分类的索引
    var _L3=0;//三级分类的索引
    function initUserListCategorys(){
        var htmlL1='<li class="first">选择分类：</li>';
        var htmlL2='<li class="first">技术领域：</li>';
        var htmlL3='<li class="first">课程产品：</li>';
        var categoryId=$("#t_categoryId").val();
        var categoryName=$("#t_categoryName").val();
        var obj=null;
        if(categoryId=="1" && categoryName=="1"){
            categoryId=-1;
        }else{
            obj=queryCategory(categoryId);
        }
        if(obj==null){
            _L=0;
            _L1=0;
            _L2=0;
            _L3=0;
        }
        for(i=0;i<category.length;i++){
            if(i==_L1){
                htmlL1+=' <li class="attributesItem selected" dataIndex="0" data="'+category[i].id+'">'+category[i].name+'</li>';
            }else{
                htmlL1+=' <li class="attributesItem" dataIndex="0" data="'+category[i].id+'">'+category[i].name+'</li>';
            }
        }
        //htmlL1+=' <li class="attributesItem" dataIndex="0" data="-1">全部</li>';
        
        var list=category[_L1].list;
        for(i=0;i<list.length;i++){
            if(i==_L2){
                htmlL2+=' <li class="attributesItem selected" dataIndex="1" data="'+list[i].id+'">'+list[i].name+'</li>';
            }else{
                htmlL2+=' <li class="attributesItem" dataIndex="1" data="'+list[i].id+'">'+list[i].name+'</li>';
            }
        }
        //htmlL2+=' <li class="attributesItem" dataIndex="1" data="-1">全部</li>';
        
        list=category[_L1].list[_L2].list;
        for(i=0;i<list.length;i++){
            if(i==_L3){
                htmlL3+='<li class="attributesItem selected" dataIndex="2" data="'+list[i].id+'">'+list[i].name+'</li>';
            }else{
                htmlL3+='<li class="attributesItem" dataIndex="2" data="'+list[i].id+'">'+list[i].name+'</li>';
            }
        }
        //htmlL3+=' <li class="attributesItem" dataIndex="2" data="-1">全部</li>';
        
        $("#categoryLevel1").html(htmlL1);
        $("#categoryLevel2").html(htmlL2);
        $("#categoryLevel3").html(htmlL3);
        if($("#categoryLevel0").length>0){
            _L=3;
        }
        if(_L>0){
            $("#categoryLevel1").addClass("hidden");
        }
        if(_L>1){
            $("#categoryLevel2").addClass("hidden");
        }
        if(_L>2){
            $("#categoryLevel3").addClass("hidden");
        }
    }
    //获取所选分类对应的各级索引，及分类所属的级
    function queryCategory(id){
        for(_L1=0;_L1<category.length;_L1++){
            _L2=0;
            _L3=0;
            if(id==category[_L1].id){
                _L=1;
                return category[_L1];
            }
            var list=category[_L1].list;
            for(_L2=0;_L2<list.length;_L2++){
                _L3=0;
                if(id==list[_L2].id){
                    _L=2;
                    return list[_L2];
                }
                var list2=list[_L2].list;
                for(_L3=0;_L3<list2.length;_L3++){
                    if(id==list2[_L3].id){
                        _L=3;
                        return list2[_L3];
                    }
                }
            }
        }
        return null;
    }
	
   //翻页
    function topage(page){
        $("#page").val(page);
        studyFormSubmit();
        }
    function turnpage(){
        var page=$("#pagenum").val();
        $("#page").val(page);
        studyFormSubmit();
    }
    
		
	/**
	 * 求学分类查询页面的条件选项点击事件注册
	 */
	function clickRegisterForStudyApply(){
		//分类
		$(".attributesItem").click(function(){
			var data=$(this).attr("data");
			var index=$(this).attr("dataIndex");
			
			if(data=="-1"){
				return dropConditionForStudyApply(index);
			}
			if(index==-1){//点击匹配到的分类
				$("#t_categoryId").val(data);
				var text=$(this).text();
				var i=text.lastIndexOf(">");
				$("#t_categoryName").val(text.substr(i+1,text.length));
			}else if(index<3){ //点击分类
				$("#t_categoryId").val(data);
				$("#t_categoryName").val($(this).text());
			}else{//点击其他筛选条件
				$("#attribute"+index).val(data);
			}
			studyFormSubmit();
		});
		//求学方式
		$(".goods_type").click(function(){
			var goodsType='';
			var types=$(".goods_type"); 
			for(var i=0;i<types.length;i++){ 
				if(types[i].checked){
					goodsType=goodsType+$(types[i]).val()+',';
				}
			}
			var sIndex=goodsType.lastIndexOf(",");
			goodsType=goodsType.substring(0,sIndex);
			$("#goodsType").val(goodsType);
			studyFormSubmit();
		})
		//求学地点
		$(".shengfen").change(function(){
			var studyAdress=$(".shengfen").val()+"_"+$(".chengshi").val()+"_"+$(".quxian").val();
			$("#address").val(studyAdress);
			studyFormSubmit();
		})
		
		$(".fd_style").click(function(){
			var fdType='';
			var types=$(".fd_style"); 
			for(var i=0;i<types.length;i++){ 
				if(types[i].checked){
					fdType=fdType+$(types[i]).val()+',';
				}
			}
			var sIndex=fdType.lastIndexOf(",");
			fdType=fdType.substring(0,sIndex);
			$("#t_fdType").val(fdType);
			studyFormSubmit();
		})
		//选择面授地点
		function selectAttribute7(){
			var shengfen=$("#shengfenSelect").val();
			var city=$("#citySelect").val();
			$("#attribute7").val(shengfen+city);
			studyFormSubmit();
		}
		//求学 全部、团队、个人
		$(".main_wz").click(function(){
			var studyTeam=$(this).attr("data");
			$("#t_isTeam").val(studyTeam);
			studyFormSubmit();
		})
		//求学只看在线
		$("#only_online").click(function(){
			if($("#only_online").is(":checked"))
				$("#t_isOnline").val("1");
			else 
				$("#t_isOnline").val("0");
			studyFormSubmit();
		})
		//求学排序
		$(".order_select").change(function(){
			$("#t_orderFiledFlat").val($(".order_select").val());
			studyFormSubmit();
		})
		//价格
		$(".jg_yes").click(function(){
			var minPrice=$("#minPriceInput").val();
			var maxPrice=$("#maxPriceInput").val();
			$("#t_minPrice").val(minPrice);
			$("#t_maxPrice").val(maxPrice);
			studyFormSubmit();
		});
	}
	
		/**
	 * 分类查询页面的表单提交（已修改：将动作放到触发提交之后,现在等效于$("#studyQueryForm").submit()）
	 */
	function studyFormSubmit(){
		$("#studyQueryForm").submit();
	}
	
	/**
	 * 分类查询页面表单提交事件
	 */
	function onStudyFormSubmit(){
		//var action=$("#studyQueryForm").attr("action");
		//$("#studyQueryForm").attr("action",action+"/"+$("#t_categoryId").val()+"/"+$("#t_categoryName").val());
	}

	
	/**
	* 生成已选条件
	*/
	function createConditionForStudyApply(){
		var html="<a href='http://www.yxit.net/js/"+_appRoot+"/'>IT易学网</a><span> > </span><a href='http://www.yxit.net/js/"+_appRoot+"/study.htm"+"'>求学</a>";
		var goodsType=$("#t_goodsType").val();
		var categoryName=$("#t_categoryName").val();
		//三级分类的选择条件
		if($("#categoryLevel1").hasClass("hidden") && $("#categoryLevel0").length==0){
			var selected=$("#categoryLevel1 .selected");
			html+="<span> > </span><a href='javascript:void(0);' onclick='dropConditionForStudyApply(0)'>"+selected.html()+"</a>";
		}
		if($("#categoryLevel2").hasClass("hidden") && $("#categoryLevel0").length==0){
			var selected=$("#categoryLevel2 .selected");
			html+="<span> > </span><a href='javascript:void(0);' onclick='dropConditionForStudyApply(1)'>"+selected.html()+"</a>";
		}
		if($("#categoryLevel3").hasClass("hidden") && $("#categoryLevel0").length==0){
			var selected=$("#categoryLevel3 .selected");
			html+="<span> > </span><a href='javascript:void(0);' onclick='dropConditionForStudyApply(2)'>"+selected.html()+"</a>";
		}
		$("#goodsAttributesDt").html(html);
	}
	
		/**
	 * 筛选条件取消
	 */
	function dropConditionForStudyApply(index){
		if(index==0){//一级分类的全部
			$("#t_categoryId").val("");
			$("#t_categoryName").val("");
			studyFormSubmit();
			return;
		}else if(index==1){//二级分类的全部
			$("#t_categoryId").val(category[_L1].id);
			$("#t_categoryName").val(category[_L1].name);
			studyFormSubmit();
			return ;
		}else if(index==2){//三级分类的全部
			$("#t_categoryId").val(category[_L1].list[_L2].id);
			$("#t_categoryName").val(category[_L1].list[_L2].name);
			studyFormSubmit();
			return ;
		}
		$("#attribute"+index).val("");
		studyFormSubmit();
		return ;
	}
	//查询讲师是否发布过商品
	function ajax4ValPulishGoods(){
		$.ajax({
			type:"POST",
			url:"/userCenter/ajax4ValPulishGoods",
			dataType:"json",
			success: function(data){
				if(data.result==1){
					if(data.flag==1){
					}else{						
						$("#qianxuan_sendInv").html("<a href='javascript:toPublicGoods();' ><input type='button' class='kk_yq' value='发送开课邀请' /></a>");
						$(".send_invite").html("<a href='javascript:toPublicGoods();' >发送开课邀请</a>");
					}
				}
			}
		});
	}
	
	
	//统计邮件输入框文本字数
	function countChar(textareaID,maxNum,spanID){
		var NowNum=$(textareaID).val().length;
		if(NowNum>maxNum){
			$(textareaID).val($(textareaID).val().substr(0,maxNum));
		}
		else{
			$(spanID).text(NowNum);	
		}
	}
    //加入求学添加数量
    $(function(){
        var t = $("#text_box");
        $("#add").click(function(){        
            t.val(parseInt(t.val())+1)
        })
        $("#min").click(function(){
            t.val(parseInt(t.val())-1)
        })
    })
    //添加邮箱
    function addemail(){ 
		var email_num=$(".qiu_emails").length;
		if(email_num<=9){
		var obj = document.getElementById("adddiv");
			obj.insertAdjacentHTML("afterBegin","<input class='qiu_emails emails' type='text'/><a class='dele_btu' onclick='deleteEmail(this)'>-删除</a>");
			//$(".qiu_emails").attr("value","邮箱"+email_num);
		}
		else alert("最多输入10个邮箱!");
    }
	//删除邮箱
	function deleteEmail(a){
		$(a).prev().remove();
		$(a).remove();
	}

    //全选账号
    function chooseall(d){
		var c=$(".study_check");
		var i=0;
		if($("#choose_all").is(":checked")){
			for(i=0;i<c.length;i++){ 
				if(!$(c[i]).attr("disabled")){
					$(c[i]).attr("checked",true);
				}				
			}
		}
		else{
			for(i=0;i<c.length;i++){   
			$(c[i]).attr("checked",false);			
			}
		}
    }
	//选择开启还是关闭自动邀请
	function chooseOne(cb){      
         var obj = document.getElementsByName("yq_check");   
         for (i=0; i<obj.length; i++){    
             if (obj[i]!=cb) 
			 obj[i].checked = false;
             else obj[i].checked = true; 		 
         }
	}
	function changeCourse(){
		$("#class_address").val($("#courseSelect option:selected").attr("dataIndex"));
	}
	//提交加入求学数据
	function joinStudy(){
		var studyId=$("#study_id").val();
		if(!checkData(studyId,0,'lt')){
			clickautohide("数据异常，请刷新页面!",3);
			return ;
		}
		var peopleCount=$("#text_box").val();
		if(!checkInt(peopleCount,1,'gt')){
			clickautohide("请输入正确的求学人数!",3);
			return ;
		}
		
		var name=$(".qiu_username").val();
		if(!checkData(name,1,'lt')){
			clickautohide("请输入正确的联系人姓名",3);
			return ;
		}
		var phone=$(".qiu_userphone").val();
		if(!checkMobile(phone) && !checkPhone(phone)){
			clickautohide("请输入正确的联系方式",3);
			return ;
		}
		
		//邮箱
		var email=$(".emails");
		var emails="";
		for(var i=0;i<email.length;i++){
			if(email[i].value==""){
				break;
			}
			if(checkEmail(email[i].value)){
			emails=emails+email[i].value+",";
			}
			else{ clickautohide("邮箱格式不正确",3);return ;}
		}
		if(emails.length<=0){
			clickautohide("请输入正确的邮箱",3);
			return ;
		}
		var index=emails.lastIndexOf(",");
		emails=emails.substring(0,index);
		
		var contactTime=$(".qiu_time").val();
		
		$.ajax({
			type:"POST",
			url:"/userCenter/joinStudyApply",
			data:{id:studyId,peopleCount:peopleCount,name:name,phone:phone,email:emails,contactTime:contactTime},
			dataType:"json",
			success: function(data){
				if(data.result==1){
					clickautohide("加入成功",2);
					$("#botton_people").val(peopleCount);
					$("#botton_name").val(name);
					$("#botton_phone").val(phone);
					$("#botton_contactTime").val(contactTime);
					closePopup('-studyjoin');
				}else{
					clickautohide("加入失败:"+data.message,3);
				}
			}
		});
	}
//提交发送邀请数据	
	function sendInvite(){
		setCookie("lastCourseText",$("#zmd_h").val());
		setCookie("lastLoginTime",$("#lastLoginTime").val());
		var studyId=$("#send_stu_id").val();
		if(!checkData(studyId,0,'lt')){
			clickautohide("数据异常，请刷新页面!",3);
			return ;
		}
		var content=$("#zmd_h").val();
		if(content==""){
			content="您好！经查看您发布的求学信息，我有一个课程班级与您的期望较为符合，特邀请您查看我的课程信息。只需点击“接受邀请”，即可进入查看课程。";
		}
		else if(!checkData(content,10,'lt')){
			clickautohide("求学邀请正文不得少于10个字符!",3);
			return ;
		}
		var goodsName=$("#courseSelect option:selected").text();
		/*var goodsName=$("#goods_name").val();
		if(!checkData(goodsName,2,'lt')){
			clickautohide("请输入正确的商品名称!",3);
			return ;
		}*/
		var goodsUrl="http://www.yxit.net/browse/queryGoods/"+$("#courseSelect option:selected").attr("data");
		/*var goodsUrl=$("#goods_url").val();
		if(!checkData(goodsUrl,20,'lt')){
			clickautohide("请输入正确的商品链接!",3);
			return ;
		}*/
		var address=$("#class_address").val();
		if(!checkData(address,1,'lt')){
			clickautohide("请输入正确的上课地址!",3);
			return ;
		}
		var teacherName=$("#teacher_name").val();
		if(!checkData(teacherName,1,'lt')){
			clickautohide("请输入正确的授课讲师姓名",3);
			return ;
		}
		var phone=$("#teacher_phone").val();
		if(!checkMobile(phone) && !checkPhone(phone)){
			clickautohide("请输入正确的联系方式",3);
			return ;
		}
		var isAuto;
			if($("#open_auto").is(":checked")){
				isAuto=1;
			}
			else{
				isAuto=0;
			}
		$("#send_button").attr("disabled","disabled");
		$.ajax({
			type:"POST",
			url:"/userCenter/sendInvitation",
			async:false,
			data:{contactIds:studyId,content:content,goodsName:goodsName,goodsUrl:goodsUrl,address:address,teacherName:teacherName,phone:phone,isAuto:isAuto},
			dataType:"json",
			success: function(data){
				if(data.result==1){
					clickautohide("发送邀请成功",2);
					var invication = $("#hiddenInvication");
					$(invication).find("#content").val(content);
					$(invication).find("#goodsName").val(goodsName);
					$(invication).find("#goodsUrl").val(goodsUrl);
					$(invication).find("#address").val(address);
					$(invication).find("#teacherName").val(teacherName);
					$(invication).find("#phone").val(phone);
					$("#invitationSwtich").val(isAuto);
					closePopup('-study');
				}else{
					clickautohide("发送邀请失败:"+data.message,3);
				}
			}
		});
		$("#send_button").removeAttr("disabled","disabled");
	}
	
	function closePopup(target){
		$('#cd-popup'+target).fadeOut(300);
		$('#cd-popup'+target+' .cd-popup-container').fadeOut(300);
		$("#yi_yy").text(0);
	}
	
	
	function queryFromAddress(){
		var add_sf = $("p.shengfen").html();
		var add_cs = $("p.chengshi").html();
		var add_qx = $("p.quxian").html();
		var address ="";
		if(add_sf!='全部'){
			address+=add_sf+'_';
		}
		if(add_cs!='全部'){
			address+=add_cs+'_';
		}
		if(add_qx!='全部'){
			address+=add_qx;
		}
		$("#address").val(address);
		studyFormSubmit();
	}
	
	//
	function toPublicGoods(){
		$(".to_go_to").html("<a href='http://www.yxit.net/js/"+_appRoot+"/userCenter/categorySelect.html'>我要去发布课程>></a>");
		$(".tip_p").html("<span></span>您已是讲师，请先在讲师中心后台发布课程，复制该课程链接，才能发送开课邀请。");
		getTipDiv();
	}
	
	function toBeTeacher(){
		$(".to_go_to").html("<a href='http://www.yxit.net/js/"+_appRoot+"/userCenter/teacherApply.html'>我要申请成为讲师>></a>");
		$(".tip_p").html("<span></span>您还不是讲师，请先申请成为讲师，然后在讲师中心后台发布课程，复制该课程链接，才能发送开课邀请。");
		getTipDiv();
	}
	function getTipDiv(){
		$("#tea_tip_back").fadeIn(300);
        $("#tea_tip").fadeIn(300);	
		$("#tea_tip_back").on('click', function(event){
        if( $(event.target).is('.close_tea_tip') || $(event.target).is('#tea_tip_back') || $(event.target).is('.close_tip_but')) {
            event.preventDefault();
            $(this).fadeOut(300);
            $("#tea_tip").fadeOut(300);
        }
		});
		$(document).keyup(function(event){
        if(event.which=='27'){
            $("#tea_tip_back").fadeOut(300);
            $("#tea_tip").fadeOut(300);
        }
		});
	}